<?php
session_start();
require_once 'include/db.php';
require_once 'include/functions.php';
require_once 'include/userClass.php';
require_once 'include/postClass.php';
$post = new postClass($user -> getUserID(), $db);
$title = "Home";
include 'include/header.php';

// If user has choosen number of posts to display:
if(isset($_GET['stat'])) {
	 $num = $_GET['stat'];
}
else {
	 $num = 20;
}
?>
<div id="content">
<form id='numpostform' name='numpost' action='index.php' method='get'>
     <label>Vis</label>
	 <select name='stat' onchange='this.form.submit()'>
          <option value='10' <?php if($num==10) echo "selected";?>>10</option>
          <option value='20' <?php if($num==20) echo "selected";?>>20</option>
		  <option value='50' <?php if($num==50) echo "selected";?>>50</option>
		  <option value='100' <?php if($num==100) echo "selected";?>>100</option>
     </select>
</form>
<?php
	$post -> getLastPosts($num);
?>
</div>
<div id="side">
	<h2>Topp 10</h2>
	    <?php $post ->top10() ?>
	 <p id="toptext">* De mest populære brukerne de siste 14 dagene</p>
</div>
<?php include 'include/footer.php'?>